package com.jsg.sl651.exception;


public class DefaultException extends RuntimeException{
    private DefaultException(String message) {
        super(message);
    }
    public DefaultException(String messageTemplate,Object ... data) {
        this(toMessage(messageTemplate,data));
    }

    public static String toMessage(String messageTemplate,Object ... data) {
        if (data == null || data.length == 0) {
            return messageTemplate;
        }
        if (messageTemplate.contains("{}")) {
            messageTemplate = messageTemplate.replace("{}", "%s");
        }
        return String.format(messageTemplate, data);
    }
}
